<template>
	<view class="container">
		<view class="header">
			<view class="logo">
				<image mode="aspectFit" class="img1" :src="resBaseUrl + '/index/mjicon-small.png'" alt="" />
				<text>魔简ERP-{{name}}</text>
			</view>
			<!-- <img class="img1" :src="resBaseUrl+'user/logoname.png'" alt="" /> -->
			<!-- <image mode="aspectFit" class="img2" :src="resBaseUrl + '/logoInfo.png'" alt="" /> -->
			<text class="img2">
				让信息化更简单
			</text>
			<view class="search">
				<image mode="aspectFit" :src="resBaseUrl + 'index/miuis.png'" alt="" />
				<view class="row-me row-center margin-left30 margin-right30 broadcast">
					<!-- <image src="/src/static/images/user/bg.png" mode="" class="margin-left30 margin-right20 horn"></image> -->

					<swiper :circular="true" :vertical="true" :autoplay="true" :interval="3000" :duration="1000"
						class="margin-right30 swiperBox">
						<swiper-item v-for="(item, index) in noticeList" :key="index"
							class="row-me row-center swiperItem">
							<!-- {{item.time}} -->
							<view class="margin-left10 txt1">{{ item.noteTitle }}</view>
						</swiper-item>
					</swiper>
				</view>
			</view>
		</view>
		<view class="main">
			<!-- <navigator animation-type="pop-in" animation-duration="300" url="/pages/order/index"> -->
			<view v-if="homeMenu.indexOf('1000')>-1" @tap="skip('/pages/order/index')" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/fins.svg'" alt="" />
				<text class=""> 订单管理 </text>
			</view>
			<!-- 	</navigator>
			<navigator animation-type="pop-in" animation-duration="300" url="/pages/product/index"> -->
			<view v-if="homeMenu.indexOf('1001')>-1" @tap="skip('/pages/product/index')" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/tv.svg'" alt="" />
				<text class=""> 产品管理 </text>
			</view>
			<!-- </navigator>
			<navigator animation-type="pop-in" animation-duration="300" url="/pages/customer/index"> -->
			<view v-if="homeMenu.indexOf('1002')>-1" @tap="skip('/pages/customer/index')" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/menu.svg'" alt="" />
				<text class=""> 客户管理 </text>
			</view>
			<!-- </navigator>
			<navigator animation-type="pop-in" animation-duration="300" url="/pages/purchasing/index"> -->
			<view v-if="homeMenu.indexOf('1003')>-1" @tap="skip('/pages/purchasing/index')" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/cart.svg'" alt="" />
				<text class=""> 采购管理 </text>
			</view>
			<!-- </navigator>
			<navigator animation-type="pop-in" animation-duration="300" url="/pages/financial/index"> -->
			<view v-if="homeMenu.indexOf('1004')>-1" @tap="skip('/pages/financial/index')" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/card.svg'" alt="" />
				<text class=""> 财务管理 </text>
			</view>
			<!-- </navigator> -->
			<!-- <navigator animation-type="pop-in" animation-duration="300" url="/pages/datas/index"> -->
			<view v-if="homeMenu.indexOf('1005')>-1" @tap="skip('/pages/datas/index')" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/fine.svg'" alt="" />
				<text class=""> 数据管理 </text>
			</view>

			<view v-if="homeMenu.indexOf('1006')>-1" @tap="skip('/pages/labelPrinting/labelPrinting')"
				class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/label.svg'" alt="" />
				<text class=""> 标签打印 </text>
			</view>
			<view v-if="userLevel == 0" @tap="goAcc" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/menu.svg'" alt="" />
				<text class=""> 账号管理 </text>
			</view>
			<!-- </navigator> -->
			<!-- <navigator animation-type="pop-in" animation-duration="300" url="/pages/setup/setup"> -->
			<!-- <view @tap="skip('/pages/setup/setup')" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/setup.png'" alt="" />
				<text class=""> 设置 </text>
			</view> -->
			<!-- <view @tap="skip('/pages/test/test')" class="mian_item">
				<image mode="aspectFit" :src="resBaseUrl + 'index/setup.png'" alt="" />
				<text class=""> 设置 </text>
			</view> -->
			<!-- </navigator> -->
		</view>
		<!-- #ifdef MP-WEIXIN -->
		<myTabBar :showIndex="1" />
		<!-- #endif -->
		<Bluetooth ref="bluetooth" v-show="false" />
	</view>
</template>

<script>
	import myTabBar from "@/components/myTabBar.vue"
	import Bluetooth from "../setup/Bluetooth.vue"
	import {
		getQrQuery
	} from "@/utils/index";
	import {
		isNumber
	} from "../../uni_modules/uni-forms/components/uni-forms/utils";
	var app = getApp();
	export default {
		name: "index",
		components: {
			myTabBar
		},
		data() {
			const _this = this
			return {
				resBaseUrl: _this.resBaseUrl,
				imgUrl: "",
				name: "",
				homeMenu: "",
				noticeList: [],
				userLevel: -1,
			};
		},
		computed: {},
		components: {
			Bluetooth
		},
		methods: {
			goAcc() {
				/* uni.showToast({
					title:"功能开发中！",
					icon:"none"
				})
				return */
				this.skip('/pages/accountManagement/index')
			}
		},
		async onLoad() {
			// #ifdef MP-WEIXIN
			uni.hideTabBar()
			// #endif
			let data = await this.$api.qryNoticeApi()
			this.noticeList = data.result.list;

			var userInfo = app.globalData.userInfo;
			this.name = userInfo['mchCompany'];

			// console.log(this.noticeList);
		},
		created() {
			this.$nextTick(() => {
				// uni.clearStorageSync()
				// console.log(this.$refs.bluetooth.connectBluetooth1)
				this.$refs.bluetooth.searchBle()
				this.$refs.bluetooth.connectBluetooth(uni.getStorageSync("content"))
			})
		},
		onShow() {
			var userInfo = app.globalData.userInfo;
			this.userLevel = userInfo['userLevel'];
			this.name = userInfo['mchCompany'];
			this.$api.userInfoApi().then((res) => {
				if (res.code == 200) {
					// this.userInfo = res.result;
					this.$store.commit("changeMid", res.result.mid);
					// this.name = res.result.mchCompany
					this.homeMenu = res.result.homeMenu

				}
			});
			let contentFlag = uni.getStorageSync('contentFlag')
			// console.log(contentFlag)
			if (!contentFlag) {
				uni.showModal({
					content: '当前未设置默认打印参数，是否前往设置？',
					success: function(res) {
						if (res.confirm) {
							// console.log('用户点击确定');
							uni.navigateTo({
								url: "/pages/setup/Bluetooth"
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		},
	};
</script>
<style lang="scss" scoped>
	.broadcast {
		margin-top: -40rpx;
		height: 80rpx;
		background: #ffffff;
		border-radius: 20rpx;

		.horn {
			width: 40rpx;
			height: 40rpx;
		}

		.swiperBox {
			width: 500rpx;
			height: 80rpx;
			margin-left: 160rpx;
			margin-top: 40rpx;

			.horn {
				width: 40rpx;
				height: 40rpx;
			}

			.swiperItem {
				.txt1 {
					color: #000;
				}

				.txt2 {
					color: #f29a38;
				}
			}
		}
	}

	.container {
		background-color: #f1f1f1;
		height: 100vh;

		.header {
			width: 100%;
			height: 350rpx;
			background: red;
			background-size: 134% 146%;
			position: relative;
			margin-bottom: 100rpx;

			.logo {
				position: absolute;
				top: 32%;
				font-size: 48rpx;
				color: #fff;
				display: flex;
				align-items: center;
				left: 6%;

				// background-color: #f29a38;
				.text {
					margin-left: 30rpx;
					flex: 1;
				}

				.img1 {
					// position: absolute;
					// left: -20%;
					// top: 32%;
					width: 54rpx;
					height: 44rpx;
					margin-right: 30rpx;
					transform: scale(1.2);

				}
			}

			.img2 {
				position: absolute;
				left: 50%;
				top: 55%;
				transform: translateX(-50%);
				// width: 246rpx;
				height: 28rpx;
				color: #fff;
				letter-spacing: 10rpx;

			}

			.search {
				position: absolute;
				left: 50%;
				transform: translateX(-50%);
				top: 80%;
				background-color: #fff;
				width: 676rpx;
				height: 118rpx;
				border-radius: 20rpx;
				display: flex;
				justify-content: space-around;
				align-items: center;
				overflow: hidden;

				image {
					width: 50rpx;
					height: 36rpx;
					margin: 0 56rpx;
					position: absolute;
					left: 50rpx;
				}
			}
		}

		.main {
			display: grid;
			grid-template-columns: repeat(3, 1fr);
			grid-row-gap: 24rpx;
			margin-left: 70rpx;

			.mian_item {
				width: 168rpx;
				height: 168rpx;
				border-radius: 20rpx;
				background-color: #fff;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				image {
					width: 66rpx;
					height: 66rpx;
				}

				text {
					margin-top: 20rpx;
				}
			}
		}
	}
</style>
